//
//  AppController.h
//  Rainbow
//
//  Created by Alex		on 21/07/09.
//  Copyright 2009 Erasmus Software. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import <Quartz/Quartz.h>
#import "dvd.h"
#import "itemGridDVD.h"
#import "DvdGrid.h"
#import "ManagingViewController.h"
#import "AmazonCall.h"
#import "AmazonModule.h"

#define kTitle		@"Title"
#define kDirector	@"Director"
#define kType		@"Type"
#define kYear		@"Year"
#define kComment	@"Comment"
#define kTags	    @"Tags"
#define kHelloDataSourceDidChangeNotification	@"HelloDataSourceDidChangeNotification"
#define kHelloGridSourceDidChangeNotification	@"HelloGridSourceDidChangeNotification"

@class MBPreferencesController, IKImageBrowserView, ViewManager;

@interface AppController : NSPersistentDocument
{
	//data variable
	Dvd								*dvd_list;
	NSTableView						*tv;
	//window identifier => cf .xib for more details
	IBOutlet NSWindow				*add_panel;
	IBOutlet NSDrawer				*panel;
	IBOutlet NSWindow				*mainWindow;
	AmazonCall						*amazonPanel;

	//multi view variables
	NSMutableArray					*viewControllers;
	IBOutlet NSBox					*box;

	//fiels inside the information panel
	IBOutlet NSTextField			*title_field;
	IBOutlet NSTokenField			*director_field;
	IBOutlet NSTextField			*year_field;
	IBOutlet NSTokenField			*language_field;
	IBOutlet NSTokenField			*type_field;
	IBOutlet NSTokenField			*actor_field;
	IBOutlet NSTextField			*summary_field;
	IBOutlet NSTextField			*comment_field;
	IBOutlet NSTokenField			*tags_field;
	IBOutlet NSButton				*path;
	IBOutlet NSImageView			*picture;
	
	//menu bar button
	IBOutlet NSSearchField			*search_field;
	IBOutlet NSTextField			*title_add;
	IBOutlet NSButton				*edit;
	IBOutlet NSButton				*addDvdButton;
	IBOutlet NSSegmentedControl		*switch_button;
	IBOutlet NSSlider				*slideBar;
	int								searchCategory;
}

//init functions
- (id)				init;
- (void)			initSearchBar;
- (IBAction)		updateFilter:sender;


//panels and windows functions
- (void)			showPreferences:(id)sender;
- (void)			changePanelValue:(NSDictionary*)item;
- (void)			displayImage:(NSDictionary*)item;
- (IBAction)		openAmazonPanel:(id)sender;


//modification panel functions
- (IBAction)		edit_mode:(id) sender;
- (void)			mode_edit;
- (void)			mode_save;
- (IBAction)		closeButton:(id)sender;
- (void)			closeAddPanel:(id)sender;
- (IBAction)		addSheet:(id)sender;


//mandatory functions for the tableview
- (int)				numberOfRowsInTableView:(NSTableView *)tv;
- (id)				tableView:(NSTableView *)tv objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row;

//mandatory functions for the IKImageBrowserView
- (void)			imageBrowser:(IKImageBrowserView *)aBrowser removeItemsAtIndexes:(NSIndexSet *)indexes;
- (NSUInteger)		numberOfItemsInImageBrowser:(IKImageBrowserView *)aBrowser;
- (id)				imageBrowser:(IKImageBrowserView *)aBrowser itemAtIndex:(NSUInteger)index;
- (IBAction) zoomSliderDidChange:(id)sender;

//functions that handle the data
- (IBAction)		addItem:(id) sender;
- (IBAction)		removeItem:(id)sender;
- (IBAction)		choosefile:(id)sender;


//Notifications
- (void)			dataSourceDidChange:(NSNotificationCenter*)notification;
- (void)			tableViewSelection:(NSNotification *)aNotification;
- (void)			controlTextDidChange:(NSNotification *)aNotification;
- (void)			gridSelectionDidChange:(NSNotification *)notification;
- (void)			gridNoSelection:(NSNotification*)notification;

//function to swapp views
- (void)			displayViewController:(ManagingViewController *)vc;
- (IBAction)		changeViewContoller:(id)sender;
- (IBAction) exportDataBase:(id)sender;
- (IBAction) importDataBase:(id)sender;

@end
